home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 3.0 KB | 81 lines | [TEXT/GEOL] |
- Item 6388772 8-July-89 00:33
-
- From: D2215 Dac SW, Wilma Blair, PRT
-
- To: MACAPP.TECH$ MACAPP Tech
-
- cc: MACDTS Macintosh Developer Technical Supt.
-
- Sub: MacApp memory Managment
-
- I am attempting outline a strategy for handling low memory conditions.
-
- A new global function would be added:
-
- FUNCTION NewTemplateWindowMemCheck (viewRsrcId: INTEGER; itsDocument:
- TDocument): TWindow;
- BEGIN
- WHILE MemSpaceIsLow DO
- IF NOT gApplication.FreeNonCriticalMemory THEN Failure (memFullErr, );
- NewTemplateWindowMemCheck:= NewTemplateWindow (viewRsrcId, itsDocument);
- WHILE MemSpaceIsLow DO
- IF NOT gApplication.FreeNonCriticalMemory THEN Failure (memFullErr, );
- END;
-
- TApplication.FreeNonCriticalMemory: BOOLEAN; would default to false and would
- be overriden to return true if the application could free some permanent
- memory.
-
- In my application, once a view is created, I keep it around as the user may
- wish to open that window at a later time (faster to open a view than to create
- and initialize one). Such non-displayed views could be freed if a user request
- needed more memory so I would have FreeNonCriticalMemory free a view at a time
- until enough memory was available.
-
- Does this seem to be a workable strategy?
-
- In another situation, when creating an indeterminate number of objects and
- adding them to a TList (could be several thousand), I dont wish to call
- FailSpaceIsLow before adding each object as this could slow things down quite a
- bit.
-
- It would be preferable to store how much permanent memory was available before
- any objects were created in a variable and decrement this variable by the size
- of the object plus a fixed overhead (for object handle and the list, say 12
- bytes) before creating each object. I could get the amount of permanent memory
- available by the following code fragment used by the debugger:
-
- oldPerm := PermAllocation(true);
- memSpace := FreeMem;
- oldPerm := PermAllocation(oldPerm);
-
- Is this workable?
-
- I am a little unclear about what the debugger reports with the Heap Inspect
- command. The only docs I have on the MacApp memory management mechanism came
- in the Macapp 1.1 newsFlash and they seem to give contradictory information.
-
- Under the "High Water Mark" heading, it states that
-
- ...the "extra" is the sum of the sizes of objects you've allocated ... you can
- use "extra" to reserve more temporary memory...
-
- I though that the objects you allocated used permanent memory?
-
- I don't understand what the debugger items under TEMP SPACE (current temp
- space: locked, unlocked, total, purgeable) mean and how to use them.
-
- CheckReserves is only called at one place in MacApp. How should this be used?
-
- Could the forthcoming memory management docs for 2.0b9 (hopefully more clear)
- be posted to AppleLink?
-
- Also, using the debugger (Heap Show), I see that many of my segments that I
- know were never called are loaded (but not resident). I don't understand why
- they are loaded?
-
- Regards, Les Caudle
-
-
-
-